<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="vue.js"></script>
</head>
<body>
    <div id="root">
        <input type="text" v-model="msg" placeholder="已启用大写" @Keydown.capelock="showInfo">
        <h2>{{tips}}</h2>
    </div>

    <script type="text/javascript">
        Vue.config.keyCodes.capelock = 20 //定义大写按键

        new Vue({
            el:"#root",
            data:{
                msg:"",
                tips:"",
                num:1,
            },
            methods:{
                showInfo(){
                    this.num += 1;
                    if(this.num % 2 == 0){
                        this.tips="当前以切换成大写模式";
                    }else{
                        this.tips="";
                    }
                    
                }
            }
        })
    </script>
    
</body>
</html>